import scrapy
import re

class MusicSpider(scrapy.Spider):
    name = "music"

    # start_urls = ["https://music.163.com/discover/toplist?id=3778678"]
    async def start(self):
        headers = {
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
            "referer": "https: // music.163.com /"
        }
        yield scrapy.Request("https://music.163.com/discover/toplist?id=3778678",headers=headers)


    def parse(self, response):
        # print(response.text)
        items= re.findall(r'<a href="/song\?id=(\d{1,10})">(.*?)</a>',response.text)
        for item in items:
            print(item)